package stream;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.time.Time;

public class operator_filter {
    public static void main(String[] args) throws Exception {
    //   创建流式数据环
        StreamExecutionEnvironment env =  StreamExecutionEnvironment.getExecutionEnvironment();
    //    添加数据源
        DataStreamSource<Long> source = env.addSource(new oneparalleSource());

        DataStream<Long> result = source.filter(new FilterFunction<Long>() {
            public boolean filter(Long aLong) throws Exception {
                return aLong%2==0?true:false;
            }
        });
        //result.timeWindowAll(Time.seconds(2)).sum(0);
        result.print().setParallelism(2);
        env.execute("operatro_filter");
    }
}

